package com.cms.tools


import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.arouter.ArouterContains
import com.android.baselibrary.base.BaseActivity
import com.cms.tools.databinding.ActivityToolsMainBinding
import com.cms.tools.ui.AppUtils
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch


@Route(path = ArouterContains.TOOLS_MODEL)
class ToolsMainActivity :BaseActivity<ActivityToolsMainBinding>() {
    var behavior: BottomSheetBehavior<*>? = null
    override fun getLayoutId(): Int = R.layout.activity_tools_main

    override fun initView() {

        behavior = BottomSheetBehavior.from<View>(mBinding.bottomSheet)
        behavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
            override fun onStateChanged(bottomSheet: View, newState: Int) {
            }

            override fun onSlide(bottomSheet: View, slideOffset: Float) {
            }
        })
    }
    
    fun restart(view:View){
        MainScope().launch {
            delay(1600)
            AppUtils.relaunchApp(true)
        }
    }

    override fun initListener() {

    }
    fun createxml(view:View){

    }


    fun sendRedDot(view: View) {
    }

    fun lookPhoneInfo(view: View) {

    }

    fun showDialog(view: View) {
        val mBottomSheetDialog = BottomSheetDialog(this)
        val bt: View = layoutInflater.inflate(R.layout.dialog_bottom_sheet, null)
        mBottomSheetDialog.setContentView(bt)
        mBottomSheetDialog.show()
    }
    fun showBottomSheet(view: View){
        if (behavior!!.state == BottomSheetBehavior.STATE_EXPANDED) {
            behavior!!.setState(BottomSheetBehavior.STATE_COLLAPSED)
        } else {
            behavior!!.setState(BottomSheetBehavior.STATE_EXPANDED)
        }
    }

}



